package com.sumainfor.pc.market.controller.rentadviser;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.market.service.CommunityZfeignService;
import com.sumainfor.pc.market.service.FacilityService;
import com.sumainfor.pc.market.service.RdCommunityService;
import com.sumainfor.pc.market.service.RdFacilityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Date 2018年11月7日
 * @Describe 银行
 */
@RestController
@RequestMapping("/rentadviser/RdCommunityController")
public class RdCommunityController implements Serializable {
    @Autowired
    private RdCommunityService rdCommunityService;
    @Autowired
    private RdFacilityService rdFacilityService;
    @Autowired
    CommunityZfeignService communityZfeignService;
    /**
     * 查询所有的房源名称（用于下拉框筛选）
     */
    @GetMapping("/getCommunityName")
    public JsonResult getCommunityName(@RequestParam Map<String,Object> params) {
        JsonResult result=new JsonResult();
        List<Map<String,Object>> list=communityZfeignService.getCommunityName(params);
        if (list==null){
            result.error("服务器繁忙");
        }else{
            result.put(list);
        }
        return result;
    }

    /**
     * 房源上架查询小区信息
     */
    @GetMapping("/getCommunityByHouId")
    public JsonResult getCommunityByHouId(@RequestParam Map<String,Object> params){
        JsonResult result=new JsonResult();
        List<Map<String,Object>> list=null;
        Map<String,Object> map=rdCommunityService.getCommunityByHouId(params);
        if (map!=null){
            list=rdFacilityService.getFacilityListByFaid(map);
        }
        System.out.println("设备图片地址:"+list);
        if(list!=null){
            map.put("list",list);
        }
        if (map!=null){
            result.put(map);
        }else{
            result.putFailed("服务器繁忙");
        }
        return result;
    }
}
